<?php

declare(strict_types=1);

$services = [
    'V1/UserService' => App\JsonRpc\UserInterface::class,
];

return [
    'consumers' => value(function ()use($services) {
        $consumers = [];
        foreach ($services as $name => $interface) {
            $consumers[] = [
                'name' => $name,
                'service' => $interface,
//                'registry' => [
//                    'protocol' => 'consul',
//                    'address' => 'http://127.0.0.1:8500',
//                ],

                // 如果没有指定上面的 registry 配置，即为直接对指定的节点进行消费，通过下面的 nodes 参数来配置服务提供者的节点信息
                'nodes' => [
                    ['host' => '127.0.0.1', 'port' => 9669],
                ],

                'protocol' => 'jsonrpc', //协议
                'load_balancer' => 'random', // // 负载均衡算法，可选，默认值为 random

                // 配置项，会影响到 Packer 和 Transporter
                'options' => [
                    'connect_timeout' => 5.0,
                    'recv_timeout' => 5.0,
                    'settings' => [
                        // 根据协议不同，区分配置
                        'open_eof_split' => true,
                        'package_eof' => "\r\n",
                        'package_max_length' => 1024 * 1024 * 2,
                    ],

                    // 当使用 JsonRpcPoolTransporter 时会用到以下配置
                    'pool' => [
                        'min_connections' => 1,
                        'max_connections' => 32,
                        'connect_timeout' => 10.0,
                        'wait_timeout' => 3.0,
                        'heartbeat' => -1,
                        'max_idle_time' => 60.0,
                    ],
                ],
            ];
        }

        return $consumers;
    }),


];
